﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Carrousel.Model;
using System.Windows.Data;
using CarrouselPanel;
using System.Windows.Resources;
using System.Windows.Media.Imaging;
namespace Carrousel.Converters
{
    public partial class MyContent : UserControl
    {
        public MyContent()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MyContent_Loaded);
        }

        void MyContent_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 1; i <= 21; i++)
            {
                StreamResourceInfo sri = Application.GetResourceStream(new Uri("Carrousel;component/img/" + i + ".jpg", UriKind.Relative));
                BitmapImage bi = new BitmapImage();
                bi.SetSource(sri.Stream);
                Image img = new Image();
                img.Source = bi;
                img.Width = 120;
                img.Height = 200;
                this.xCarrouselPanel.AddChild(img);
            }

            this.DataContext = CarrouselModel.Instance;

            Binding bindcircleWidth = new Binding("circleWidth");
            bindcircleWidth.Mode = BindingMode.TwoWay;
            xCarrouselPanel.SetBinding(CarrouselPanel.CarrouselPanel.circleWidthProperty, bindcircleWidth);
            Binding bindcircleHeight = new Binding("circleHeight");
            bindcircleHeight.Mode = BindingMode.TwoWay;
            xCarrouselPanel.SetBinding(CarrouselPanel.CarrouselPanel.circleHeightProperty, bindcircleHeight);
            Binding bindautoPlay = new Binding("autoPlay");
            bindautoPlay.Mode = BindingMode.TwoWay;
            xCarrouselPanel.SetBinding(CarrouselPanel.CarrouselPanel.autoPlayProperty, bindautoPlay);
            Binding binddistance = new Binding("distance");
            binddistance.Mode = BindingMode.TwoWay;
            xCarrouselPanel.SetBinding(CarrouselPanel.CarrouselPanel.distanceProperty, binddistance);
        }

        private void ToLeft(object sender, RoutedEventArgs e)
        {
            xCarrouselPanel.Move(1, Distance.Left);
        }

        private void ToRight(object sender, RoutedEventArgs e)
        {
            xCarrouselPanel.Move(1, Distance.Right);
        }
    }
}
